<?php
namespace Home\Controller;
use Think\Controller;
class CommonController extends Controller {

	//功能类似构造方法  该类率先执行的方法
	public function _initialize(){
		
        //创建类模型
    	$Mclass = M('mvp_class');

    	$Mname = $Mclass->select();
    	// var_dump($Mname);
    	$this->assign('Mname',$Mname);
		
		//获取数据库
    	$link = M('mvp_friendlink');
    	//获取数据
    	$info = $link->select();
    	$this->assign('info',$info);
    	 // var_dump($info);
        //再次获取数据库
        $web = M('mvp_webconfig');
        //获取数据
        $web = $web->select();
        // var_dump($web);
        $this->assign('web',$web);
        // var_dump($web);
        if($web['0']['switch'] == 0){
            $this->error('网站正在维护中.....请稍后!',U('Home/Safeguard/safeguard'),3);
            return false;
        }
        $useraddress = M('mvp_info');
        $useraddressinfo = $useraddress->where('uid = '.$_SESSION['id'])->find();
        // var_dump($useraddressinfo);
        $this->assign('useraddressinfo',$useraddressinfo);
        $users = M('mvp_user');
        $usersinfo = $users->where('id = '.$_SESSION['id'])->find();
        // var_dump($usersinfo);
        $this->assign('usersinfo',$usersinfo);
        //var_dump($web); 
        
        //又获取数据库
        $help = M('mvp_help');
        //获取数据
        $helps = $help->select();
        $this->assign('helps',$helps); 


        //获取第四次数据库
        $Shuffling = M('mvp_shuffling');
        //获取数据
        $lb = $Shuffling->select();
        $this->assign('lb',$lb);
        // var_dump($lb);    

         //判断是否登录
        //用户的登陆检测
       
        if(empty($_SESSION['id'])){
            $id = 'true';
        }else{
            $id = $_SESSION['id'];
        }
        // var_dump($id);
        $this->assign('id',$id);

	}

	

}